import { Matrix4 } from "three";
import Geo from "../gameObject/Geo";
import Mat from "../gameObject/Mat";
import Mesh from "./Mesh";
import GameApplication from "../../system/GameApplication";
import Frame from "../gameObject/Frame";
import MeshLD from "./MeshLD";

export default class BB2RUVMesh extends MeshLD {


    public constructor(name: string, W: number, H: number, D: number) {


        const geo = new Geo({
            data: {
                'a_Position': {
                    size: 3, array: new Float32Array(
                        [
                            -W, D, H,
                            -W, D, -H,
                            W, D, -H,
                            W, D, H,
                        ])
                },
            },
            element: { array: new Uint16Array([0, 1, 2, 0, 2, 3]) }
        });
        const mat = new Mat({
            program: 'BB2',
            mode: ['TRIANGLES'],
            data: {
                'u_PvM4': { type: 'uniformMatrix4fv', value: new Matrix4().elements },
                'u_ModelM4': { type: 'uniformMatrix4fv', value: new Matrix4().elements },
            },
        });


        super(name, { geo: geo, mat: mat });

        this.setUniform('u_PvM4', { value: this.pvM4.elements });
    }

    public setTextureDraw(texture: any) {
        const { gl } = this;
        this.addTexureNew(gl, { 'u_Sampler': { texture: texture } });
    }


}